<?php

namespace app\admin\model\air;

use think\Model;
use app\admin\model\air\CustomTravel;


class Custom extends Model
{

    

    

    // 表名
    protected $name = 'air_custom';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'travel_type_text'
    ];
    

    
    public function getTravelTypeList()
    {
        return ['1' => __('Travel_type 1'), '2' => __('Travel_type 2'), '3' => __('Travel_type 3')];
    }


    public function getTravelTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['travel_type']) ? $data['travel_type'] : '');
        $list = $this->getTravelTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function travels()
    {
        return $this->hasMany(CustomTravel::class, 'air_custom_id', 'id');
    }


}
